#if defined(_MSC_VER)
#pragma once
#endif

#ifndef LM_TEXTURE_MIX_H
#define LM_TEXTURE_MIX_H

#include "../core/lm.h"
#include "../core/texture.h"

template<typename T>
class MixTexture : public Texture<T> {
public:
	MixTexture(Reference<Texture<T>> t1, Reference<Texture<T>> t2, Reference<Texture<float>> amt) {
		tex1 = t1;
		tex2 = t2;
		amount = amt;
	}
	T Evaluate(const Intersection &isect) const {
		float amt = amount->Evaluate(isect);
		return (1.f - amt) * tex1->Evaluate(isect) + amt * tex2->Evaluate(isect);
	}
	~MixTexture() {
		tex1 = NULL;
		tex2 = NULL;
		amount = NULL;
	}
private:
	Reference<Texture<T>> tex1, tex2;
	Reference<Texture<float>> amount;
};
#endif	// LM_TEXTURE_MIX_H